﻿using System;
using System.Collections.Generic;
using System.Linq;

using Moe.ECamel.Common.Entities;

namespace Moe.ECamel.Server.BL
{
	public class MailMessageBL : ECamelBL
	{
		public MailMessageBL(ECamelDataContext dataContext) 
			: base(dataContext)
		{
		}

		public void CreateMessage(MailMessage mailMessage)
		{
			this.dataContext.MailMessages.InsertOnSubmit(mailMessage);
		}

		public IList<MailMessage> GetMailMessagesByUserId(int userId)
		{
			return (from m in dataContext.MailMessages
			        where m.UserId == userId
					orderby m.SentOn descending 
			        select m).ToList();
		}
	}
}
